package cn.tedu.shoot;

import java.awt.image.BufferedImage;
import java.util.Random;

//小蜜蜂
public class Bee extends FlyingObject implements EnemyAward{
    private int xSpeed;//x坐标移动速度
    private int ySpeed;//y坐标移动速度
    private int awardType;//奖励类型

    public Bee(){
        super(60,51);
        xSpeed = 1;
        ySpeed = 2;
        Random rand = new Random();
        awardType = rand.nextInt(2);
    }
    public void step(){
        x += xSpeed;
        y += ySpeed;
        if(x<=0 || x>=400-width){//如果小蜜蜂的x<=0或者x>=400-width 说明到两头了
            xSpeed*=-1;//切换方法，正变负，负变正
        }
    }

    public int getAwardType() {
        return awardType;
    }

    int index = 1; //下标
    /** 重写getImage()获取图片 */
    public BufferedImage getImage(){ //每10毫秒走一次
        if(isLive()){
            return Images.bees[0];
        }else if(isDead()){
            BufferedImage img = Images.bees[index++];
            if(index==Images.bees.length){
                state = REMOVE;
            }
            return img;
        }
        return null;
    }
}
